package com.androidx.p013lv.mine.activity;

import android.graphics.drawable.ColorDrawable;
import android.view.View;
import android.widget.PopupWindow;
import android.widget.TextView;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.LinearLayoutManager;
import com.androidx.p013lv.base.http.BaseRes;
import com.androidx.p013lv.base.p015ui.BaseActivity;
import com.androidx.p013lv.base.utils.NetUtil;
import com.androidx.p013lv.base.utils.TimeUtils;
import com.androidx.p013lv.base.utils.ToastUtils;
import com.androidx.p013lv.base.utils.UiUtils;
import com.androidx.p013lv.base.view.StatusControlLayout;
import com.androidx.p013lv.mine.C1207R;
import com.androidx.p013lv.mine.adapter.PickerAdapter;
import com.androidx.p013lv.mine.adapter.WalletHistoryAdapter;
import com.androidx.p013lv.mine.bean.WalletHistoryBean;
import com.androidx.p013lv.mine.databinding.ActivityWalletHistoryDetailLayoutBinding;
import com.androidx.p013lv.mine.model.WalletModel;
import com.contrarywind.listener.OnItemSelectedListener;
import com.contrarywind.view.WheelView;
import com.gyf.immersionbar.ImmersionBar;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import com.scwang.smartrefresh.layout.listener.OnRefreshListener;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.List;

/* renamed from: com.androidx.lv.mine.activity.WalletHistoryDetailActivity */
public class WalletHistoryDetailActivity extends BaseActivity<ActivityWalletHistoryDetailLayoutBinding> implements OnRefreshListener {
    private WalletHistoryAdapter adapter;
    private int count = 1;
    private WalletModel model;
    private List<String> months;
    private PopupWindow pickerView;
    private int selectMonth;
    public int type;

    /* access modifiers changed from: protected */
    @Override // com.androidx.p013lv.base.p015ui.BaseActivity
    public void initImmersionBar() {
        super.initImmersionBar();
        ImmersionBar.with(this).titleBar(((ActivityWalletHistoryDetailLayoutBinding) this.binding).toolbar).init();
    }

    @Override // com.androidx.p013lv.base.p015ui.BaseActivity
    public int setLayout() {
        return C1207R.C1212layout.activity_wallet_history_detail_layout;
    }

    /* access modifiers changed from: protected */
    @Override // com.androidx.p013lv.base.p015ui.BaseActivity
    public void initView() {
        super.initView();
        this.model = (WalletModel) new ViewModelProvider(this).get(WalletModel.class);
        ((ActivityWalletHistoryDetailLayoutBinding) this.binding).setClick(new OnClick());
        ((ActivityWalletHistoryDetailLayoutBinding) this.binding).setType(Integer.valueOf(this.type));
        this.months = new ArrayList(Arrays.asList(UiUtils.getStringArray(C1207R.array.selected_month)));
        this.adapter = new WalletHistoryAdapter();
        ((ActivityWalletHistoryDetailLayoutBinding) this.binding).include.recycler.setLayoutManager(new LinearLayoutManager(this));
        ((ActivityWalletHistoryDetailLayoutBinding) this.binding).include.recycler.setAdapter(this.adapter);
        ((ActivityWalletHistoryDetailLayoutBinding) this.binding).include.refresh.setEnableLoadMore(false);
        ((ActivityWalletHistoryDetailLayoutBinding) this.binding).include.refresh.setOnRefreshListener(this);
        ((ActivityWalletHistoryDetailLayoutBinding) this.binding).include.statusLayout.setOnRetryListener(new View.OnClickListener() {
            /* class com.androidx.p013lv.mine.activity.WalletHistoryDetailActivity.View$OnClickListenerC12791 */

            public void onClick(View view) {
                ((ActivityWalletHistoryDetailLayoutBinding) WalletHistoryDetailActivity.this.binding).setStatus(2);
                WalletHistoryDetailActivity walletHistoryDetailActivity = WalletHistoryDetailActivity.this;
                walletHistoryDetailActivity.walletHistoryData(walletHistoryDetailActivity.selectMonth);
            }
        });
        this.model.dataWalletHistory().observe(this, new Observer<BaseRes<List<WalletHistoryBean>>>() {
            /* class com.androidx.p013lv.mine.activity.WalletHistoryDetailActivity.C12802 */

            public void onChanged(BaseRes<List<WalletHistoryBean>> baseRes) {
                WalletHistoryDetailActivity.this.hideLoading();
                if (baseRes.getCode() == 200) {
                    List<WalletHistoryBean> data = baseRes.getData();
                    if (data == null || data.size() == 0) {
                        ((ActivityWalletHistoryDetailLayoutBinding) WalletHistoryDetailActivity.this.binding).setStatus(4);
                    } else {
                        WalletHistoryDetailActivity.this.adapter.setData(data);
                    }
                } else {
                    ((ActivityWalletHistoryDetailLayoutBinding) WalletHistoryDetailActivity.this.binding).setStatus(1);
                }
            }
        });
        this.selectMonth = Calendar.getInstance().get(2) + 1;
        ((ActivityWalletHistoryDetailLayoutBinding) this.binding).setStatus(2);
        walletHistoryData(this.selectMonth);
    }

    /* access modifiers changed from: protected */
    @Override // com.androidx.p013lv.base.p015ui.BaseActivity
    public void initData() {
        super.initData();
        initPickView();
    }

    @Override // com.scwang.smartrefresh.layout.listener.OnRefreshListener
    public void onRefresh(RefreshLayout refreshLayout) {
        walletHistoryData(this.selectMonth);
    }

    private void initPickView() {
        View inflate = View.inflate(this, C1207R.C1212layout.pickerview_custom_options, null);
        WheelView wheelView = (WheelView) inflate.findViewById(C1207R.C1210id.wheel_view);
        Calendar instance = Calendar.getInstance();
        ((TextView) inflate.findViewById(C1207R.C1210id.tv_picker_year)).setText(instance.get(1) + "年");
        inflate.findViewById(C1207R.C1210id.tv_out).setOnClickListener(new View.OnClickListener() {
            /* class com.androidx.p013lv.mine.activity.WalletHistoryDetailActivity.View$OnClickListenerC12813 */

            public void onClick(View view) {
                WalletHistoryDetailActivity.this.pickerView.dismiss();
            }
        });
        inflate.findViewById(C1207R.C1210id.tv_finish).setOnClickListener(new View.OnClickListener() {
            /* class com.androidx.p013lv.mine.activity.WalletHistoryDetailActivity.View$OnClickListenerC12824 */

            public void onClick(View view) {
                WalletHistoryDetailActivity walletHistoryDetailActivity = WalletHistoryDetailActivity.this;
                walletHistoryDetailActivity.selectMonth = walletHistoryDetailActivity.count;
                ((ActivityWalletHistoryDetailLayoutBinding) WalletHistoryDetailActivity.this.binding).setSelectMonth(Integer.valueOf(WalletHistoryDetailActivity.this.selectMonth));
                WalletHistoryDetailActivity.this.pickerView.dismiss();
                ((ActivityWalletHistoryDetailLayoutBinding) WalletHistoryDetailActivity.this.binding).setStatus(2);
                WalletHistoryDetailActivity walletHistoryDetailActivity2 = WalletHistoryDetailActivity.this;
                walletHistoryDetailActivity2.walletHistoryData(walletHistoryDetailActivity2.selectMonth);
            }
        });
        inflate.findViewById(C1207R.C1210id.tv_cancel).setOnClickListener(new View.OnClickListener() {
            /* class com.androidx.p013lv.mine.activity.WalletHistoryDetailActivity.View$OnClickListenerC12835 */

            public void onClick(View view) {
                WalletHistoryDetailActivity.this.pickerView.dismiss();
            }
        });
        wheelView.setCyclic(false);
        wheelView.setAdapter(new PickerAdapter(this.months));
        wheelView.setOnItemSelectedListener(new OnItemSelectedListener() {
            /* class com.androidx.p013lv.mine.activity.WalletHistoryDetailActivity.C12846 */

            @Override // com.contrarywind.listener.OnItemSelectedListener
            public void onItemSelected(int i) {
                WalletHistoryDetailActivity.this.count = i + 1;
            }
        });
        wheelView.setDividerColor(getResources().getColor(C1207R.C1208color.transparent));
        wheelView.setTextSize(22.0f);
        wheelView.setTextColorOut(getResources().getColor(C1207R.C1208color.pickOutColor));
        wheelView.setTextColorCenter(getResources().getColor(C1207R.C1208color.white));
        PopupWindow popupWindow = new PopupWindow(inflate, -1, -1);
        this.pickerView = popupWindow;
        popupWindow.setOutsideTouchable(true);
        this.pickerView.setBackgroundDrawable(new ColorDrawable());
        this.pickerView.setAnimationStyle(C1207R.C1214style.PopAnimation);
    }

    public void walletHistoryData(int i) {
        if (!NetUtil.isNetworkAvailable()) {
            ToastUtils.getInstance().showWrong(UiUtils.getString(C1207R.string.hit_no_net));
            return;
        }
        this.adapter.clear();
        Calendar instance = Calendar.getInstance();
        this.model.walletHistory(this.type, TimeUtils.getFirstDayOfMonth1(instance.get(1), i), TimeUtils.getLastDayOfMonth1(instance.get(1), i));
    }

    public void hideLoading() {
        ((ActivityWalletHistoryDetailLayoutBinding) this.binding).setStatus(0);
        ((ActivityWalletHistoryDetailLayoutBinding) this.binding).setStatusRefresh(1);
    }

    public static void showStatusView(StatusControlLayout statusControlLayout, int i) {
        statusControlLayout.showStatusView(i);
    }

    public static void refreshStatus(SmartRefreshLayout smartRefreshLayout, int i) {
        if (i == 1) {
            smartRefreshLayout.finishLoadMore();
            smartRefreshLayout.finishRefresh();
        }
        if (i == 2) {
            smartRefreshLayout.finishLoadMore(0, true, true);
        }
    }

    /* renamed from: com.androidx.lv.mine.activity.WalletHistoryDetailActivity$OnClick */
    public class OnClick {
        public OnClick() {
        }

        public void btnBack() {
            WalletHistoryDetailActivity.this.finish();
        }

        public void pickerViewShow() {
            WalletHistoryDetailActivity.this.pickerView.showAtLocation(((ActivityWalletHistoryDetailLayoutBinding) WalletHistoryDetailActivity.this.binding).rootView, 17, 0, 0);
        }
    }

    /* access modifiers changed from: protected */
    @Override // androidx.appcompat.app.AppCompatActivity, androidx.fragment.app.FragmentActivity, com.androidx.p013lv.base.p015ui.BaseActivity
    public void onDestroy() {
        WalletModel walletModel = this.model;
        if (walletModel != null) {
            walletModel.cancelHttp();
        }
        super.onDestroy();
    }
}
